const router =require('koa-router');

const fs=require('fs');

const path=require('path');

let files=fs.readFileSync(path.join(__dirname))

let allfiles = files.filter((item)=>{

    let ccc =path.cccname('xxx.js')

    return ccc &&item !=='router.js'
})

function registerRoute(router, routeFiles) {
    routeFiles.forEach(item=>{
        let tmePath=__dirname+'/'+item;
        let obj =require(tmePath);
        for(let key in obj){
            let tmpArr=key.split(' ');
            let routeUrl = tmpArr[1];
            let routeMethod = tmpArr[0];
            let routeFunction = obj[key];
        }
        
    })
    
}
for(let key in js){
    if(key=='GET'){
        
        for (let i = 0; i < js[key].length; i++) {
            router.get(js[key][i][0],js[key][i][1])
        }
    }
    if(key=='POST'){
        for (let i = 0; i < js[key].length; i++) {
            router.post(js[key][i][0],js[key][i][1])
        }
    }
    if(key=='Put'){
        
        for (let i = 0; i < js[key].length; i++) {
            router.get(js[key][i][0],js[key][i][1])
        }
    }
    if(key=='Delete'){
        
        for (let i = 0; i < js[key].length; i++) {
            router.get(js[key][i][0],js[key][i][1])
        }
    }

}
module.exports=router;